<?php $this->load->view("partial/header"); ?>
<div id="page_title" style="margin-bottom:8px;"><?php echo $this->lang->line('reports_report_input'); ?></div>
<?php
if(isset($error))
{
	echo "<div class='error_message'>".$error."</div>";
}
?>	
		<?php echo form_label($this->lang->line('date').':', 'payroll_date',array('class'=>'required wide')); ?>
		<?php echo form_input(array(
		'name'=>'payroll_date',
		'id'=>'payroll_date',
		'value'=>date('F d, Y'))
		);?>
		
		<?php
			echo form_button(array(
			'name'=>'payroll_date_btn',
			'id'=>'payroll_date_btn',
			'class'=>'submit_button'),$this->lang->line('date')
			);
		?>
		<script type="text/javascript">
                  new Calendar({
                          inputField: "payroll_date",
                          dateFormat: "%B %d, %Y",
                          trigger: "payroll_date_btn",
                          bottomBar: true,
						  showTime: false,
						  animation: true,
                          onSelect: function() {
                              this.hide();
                          }
						 });
                </script>

	<?php /*echo form_label($this->lang->line('date'), 'report_date_range_label', array('class'=>'required')); ?>
	<!--
	<div id='report_date_range_simple'>
		<input type="radio" name="report_type" id="simple_radio" value='simple' checked='checked'/>
		<?php echo form_dropdown('report_date_range_simple',$report_date_range_simple, '', 'id="report_date_range_simple"'); ?>
	</div>
	
	<div id='report_date_range_complex'>
		<input type="radio" name="report_type" id="complex_radio" value='complex' />
		<?php echo form_dropdown('start_month',$months, $selected_month, 'id="start_month"'); ?>
		<?php echo form_dropdown('start_day',$days, $selected_day, 'id="start_day"'); ?>
		<?php echo form_dropdown('start_year',$years, $selected_year, 'id="start_year"'); ?>
		-
		<?php echo form_dropdown('end_month',$months, $selected_month, 'id="end_month"'); ?>
		<?php echo form_dropdown('end_day',$days, $selected_day, 'id="end_day"'); ?>
		<?php echo form_dropdown('end_year',$years, $selected_year, 'id="end_year"');  */?>
	<!--</div>-->
	<br>
	<?php echo form_label($this->lang->line('reports_staff_to_apply'), 'manage', array('class'=>'required')); ?>
	<div id="table_holder">
		<?php echo $manage; ?>
	</div>

<?php
echo form_button(array(
	'name'=>'generate_report',
	'id'=>'generate_report',
	'content'=>$this->lang->line('common_submit'),
	'class'=>'submit_button')
);
?>

<?php $this->load->view("partial/footer"); ?>

<script type="text/javascript" language="javascript">
$(document).ready(function()
{
    init_table_sorting();
    enable_select_all();
    enable_checkboxes();
    enable_row_selection();
  
	$("#generate_report").click(function()
	{
		if($("#sortable_table tbody :checkbox:checked").length >0)
		{
			if($("#payroll_date").val().length > 0)
			{
				var row_ids = get_selected_values();
				var payroll_date = $("#payroll_date").val();
				window.location = window.location+'/'+payroll_date + '/'+ row_ids;
			}
			else
			{	
				alert('Date is Required');
			}
		}
		else
		{	
			alert('<?php echo $this->lang->line('common_none_selected'); ?>');
		}
	});
	/*
		if ($("#simple_radio").attr('checked'))
		{
			window.location = window.location+'/'+$("#report_date_range_simple option:selected").val();
		}
		else
		{
			var start_date = $("#start_year").val()+'-'+$("#start_month").val()+'-'+$('#start_day').val();
			var end_date = $("#end_year").val()+'-'+$("#end_month").val()+'-'+$('#end_day').val();
	
			window.location = window.location+'/'+start_date + '/'+ end_date;

		}
		
	$("#start_month, #start_day, #start_year, #end_month, #end_day, #end_year").click(function()
	{
		$("#complex_radio").attr('checked', 'checked');
	});
	
	$("#report_date_range_simple").click(function()
	{
		$("#simple_radio").attr('checked', 'checked');
	});
	*/
});

function init_table_sorting()
{
	//Only init if there is more than one row
	if($('.tablesorter tbody tr').length >1)
	{
		$("#sortable_table").tablesorter(
		{ 
			sortList: [[1,0]], 
			headers: 
			{ 
				0: { sorter: false}, 
				7: { sorter: false} 
			} 

		}); 
	}
}
</script>